<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <div id="app">
        <!-- 事件绑定 -->
        <!-- v-on:click可以简写为@click -->
        <button @click="num++">点赞</button>
        <button v-on:click="cancle()">取消</button>
        <h1>有{{num}}个赞</h1>

        <!-- 事件修饰符 -->
        <div style="border: 1px solid red; padding: 20px;" @click="clicked()">
            大div
            <div style="border: 1px solid blue; padding: 20px;" @click.stop="clicked()">
                小div<br />
                <a href="http://www.baidu.com" @click.prevent.stop="clicked()">去百度</a>
            </div>
        </div>

        <!-- 按钮修饰符 -->
        <input type="text" v-model="num" @keyup.up="num+=2" @keyup.down="num-=1" @click.ctrl="num+=10"><br />
        提示：
    </div>
    <script>
        let vm = new Vue({
            el: "#app",
            data: {
                num: 1


            },
            methods: {
                cancle() {
                    this.num--;
                },
                clicked() {
                    alert("点击了");
                }
            },
        });
    </script>
</body>

</html>